<?php

namespace app\admin\controller;

use app\admin\BaseController;
use app\admin\model\SheshiModel;

class Facility extends BaseController
{
    public function query()
    {
        $sheshiModel = SheshiModel::where('village_id',$this->villageId)->find();
        return show($sheshiModel);
    }

    public function edit()
    {
        $params = $this->request->param();
        $sheshiModel = SheshiModel::where('village_id',$this->villageId)->find();

        if ($sheshiModel === null) {
            $params['village_id'] = $this->villageId;
            SheshiModel::create($params);
        } else {
            $sheshiModel->gc = $params['gc'];
            $sheshiModel->kdzd = $params['kdzd'];
            $sheshiModel->lkjk = $params['lkjk'];
            $sheshiModel->ljflz = $params['ljflz'];
            $sheshiModel->save();
        }

        return show();
    }

}